package com.hksj.Intelligentmanagement.controller;

import com.hksj.Intelligentmanagement.common.Result;
import com.hksj.Intelligentmanagement.dto.DictDTO;
import com.hksj.Intelligentmanagement.service.DictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/dict")
@Api(tags = "字典管理")
public class DictController {
    @Autowired
    private DictService dictService;

    @ApiOperation(value = "新增字典")
    @PostMapping("/addDict")
    public Result addDict(@RequestBody DictDTO dictDTO) {
        return dictService.addDict(dictDTO);
    }

    @ApiOperation(value = "删除字典")
    @DeleteMapping("/deleteDict/{id}")
    public Result deleteDict(@PathVariable("id") String id) {
        return dictService.deleteDict(id);
    }

    @ApiOperation(value = "更新字典")
    @PostMapping("/updateDict")
    public Result updateDict(@RequestBody DictDTO dictDTO) {
        return dictService.updateDict(dictDTO);
    }

    @ApiOperation(value = "分页查询父字典列表")
    @PostMapping("/queryDictByPage")
    public Result queryDictByPage(@RequestBody DictDTO dictDTO) {
        return dictService.queryDictByPage(dictDTO);
    }

    @ApiOperation(value = "根据id查询子字典列表")
    @PostMapping("/queryChildDictByPidId")
    public Result queryChildDictByPidId(String id) {
        return dictService.queryChildDictByPidId(id);
    }

    @ApiOperation(value = "根据id查询单个字典")
    @GetMapping("/queryDictById/{id}")
    public Result queryDictById(@PathVariable String id) {
        return dictService.queryDictById(id);
    }

}
